﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

/// <summary>
/// Summary description for Utility
/// </summary>
public static class Utility
{
    public static void SendValidateCode(string userName, string number, string code)
    {
        number = number + "@139.com";
        string title = "感谢您的注册，您的验证码：" + code;
        SendMail.Send(number, title, ".", false, ConstStrings.RootMail);
    }

    public static void CheckLoginAndRedirect()
    {
        if (!HttpContext.Current.User.Identity.IsAuthenticated)
        {
            HttpContext.Current.Session["LastUrl"] = HttpContext.Current.Request.UrlReferrer.ToString();

            HttpContext.Current.Response.Redirect("./Logon.aspx");
        }
        global::User user = UserManager.GetInstance().FindUser(HttpContext.Current.User.Identity.Name);
        if (!user.IsValidate)
        {
            HttpContext.Current.Session["LastUrl"] = HttpContext.Current.Request.UrlReferrer.ToString();

            HttpContext.Current.Response.Redirect("./Validate.aspx");
        }
    }
}
